package com.ha.mapper;

import com.github.pagehelper.Page;
import com.ha.annotation.AutoFill;
import com.ha.dto.GarbageKindDTO;
import com.ha.dto.GarbageKindPageDTO;
import com.ha.entity.GarbageKind;
import com.ha.enumeration.OperationType;
import com.ha.vo.KindIdVO;
import com.ha.vo.UserGarbageVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * ClassName: GarbageKindMapper
 * Package: com.ha.service.aspect
 * Description:
 *
 * @Author 那啥啥
 * @Create 2024/4/20  0:04
 * @Version 1.0
 */
@Mapper
public interface GarbageKindMapper {
    @AutoFill(OperationType.INSERT)
    @Insert("insert into rubbish_kind(kind, create_time, update_time, image,create_user,update_user) VALUES " +
            "(#{kind},#{createTime},#{updateTime},#{image},#{createUser},#{updateUser})")
    void insertKind(GarbageKind garbageKind);

    @Select("select kind from rubbish_kind where kind = #{kind}")
    GarbageKind getByKind(String kind);


    Page<GarbageKind> pageQuery(GarbageKindPageDTO garbageKindPageDTO);

    @Delete("delete from rubbish_kind where  id= #{id}")
    void deleteById(Long id);

    @AutoFill(OperationType.UPDATE)
    void update(GarbageKind garbageKind);

    @Select("select *from rubbish_kind where id = #{id}")
    GarbageKind getById(Long id);

    @Select("select id, kind from rubbish_kind ")
    List<KindIdVO> getKindVOList();

    @Select("select *from rubbish where name like concat('%',#{name},'%')")
    List<UserGarbageVO> getByName(String name);
}
